{include file="public/_meta" /}
<body>
<style>
    .required_b{
        color: red;
    }
</style>
<div class="wrapper">

    {include file="public/_header" /}

    <!-- Sidebar -->
    {include file="public/_menu" /}
    <!-- End Sidebar -->

    <div class="main-panel">

        <div class="content">
            <div class="page-inner">

                <!-- 面包屑 -->
                {include file="public/_page_header" /}

                <div class="row">
                    <div class="col-md-12">
                        <div class="card">
                            <div class="card-header">
                                <div class="d-flex align-items-center">
                                    <h4 class="card-title">费用充值</h4>
                                </div>

                                <form class="row">

                                    <div class="col-md-6 col-lg-2">
                                        <div class="form-group">
                                            <input type="text" class="form-control" name="mer_name" value="{$mer_name}" placeholder="请输入商户名称">
                                        </div>
                                    </div>

                                    <div class="col-md-6 col-lg-2">
                                        <div class="form-group">
                                            <input type="text" class="form-control" name="mobile" value="{$mobile}" placeholder="请输入手机号">
                                        </div>
                                    </div>

                                    <div class="col-md-6 col-lg-2">
                                        <div class="form-group">
                                            <input type="text" class="form-control" name="times" id="times" value="{$times}" placeholder="时间">
                                        </div>
                                    </div>

                                    <div class="col-md-6 col-lg-2">
                                        <div class="form-group">

                                            <select class="form-control input-full" name="orderb" id="orderb">
                                                <option value="9">创建时间升序</option>
                                                <option value="10">创建时间倒叙</option>
                                                <option value="">默认排序</option>
                                                <option value=1>消耗升序</option>
                                                <option value=2>消耗降序</option>
                                                <option value=3>余额升序</option>
                                                <option value=4>余额降序</option>
                                                <option value=5>充值升序</option>
                                                <option value=6>充值降序</option>
                                                <option value=7>凤翥升序</option>
                                                <option value=8>凤翥降序</option>
                                            </select>
                                        </div>
                                    </div>



                                    <div class="col-md-6 col-lg-2">
                                        <div class="form-group">
                                            <button type="submit" class="btn btn-primary">查询</button>
                                            <a href="{:url('stat/prices')}" class="btn btn-info" style="color: white;position: absolute;left: 110px;">重置</a>
                                        </div>
                                    </div>

                                </form>

                            </div>

                            <div class="layui-card-body">

                                <blockquote class="layui-elem-quote layui-quote-nm">
                                    <span style="margin-right: 50px;">真实币：{$fzmoney}</span><span style="margin-right: 50px;">账户币：{$moneys}</span><span style="margin-right: 50px;">消耗金额：{$clueall}</span><span style="margin-right: 50px;">账户币余额：{$timemoney}</span><span style="margin-right: 50px;">真实币余额：{$timemoney2}</span><span style="margin-right: 50px;">当前账户币余额：{$mall}</span><span style="margin-right: 50px;">当前真实币余额：{$mall}</span>

                                </blockquote>
                            </div>


                            <div class="card-body">
                                <!-- Modal -->
                                <div class="modal fade" id="addRowModal" tabindex="-1" role="dialog" aria-hidden="true">
                                    <div class="modal-dialog" role="document">
                                        <div class="modal-content">
                                            <div class="modal-header no-bd">
                                                <h5 class="modal-title">
                                                    <span class="fw-mediumbold">充值</span>

                                                </h5>
                                                <button type="button" class="close" data-dismiss="modal" aria-label="Close">
                                                    <span aria-hidden="true">&times;</span>
                                                </button>
                                            </div>
                                            <div class="modal-body">
                                                <form id="form-modal">
                                                    <div class="row">

                                                        <div class="form-group form-inline col-md-12">
                                                            <label for="mer_name" class="col-md-3 col-form-label"><font style="vertical-align: inherit;">充值商户</font></label>
                                                            <div class="col-md-8 p-0">
                                                                <input type="text" disabled class="form-control input-full" id="mer_name" name="mer_name" value="">
                                                            </div>
                                                        </div>

                                                        <div class="form-group form-inline col-md-12">
                                                            <label for="" class="col-md-3 col-form-label"><font style="vertical-align: inherit;">账户币余额</font></label>
                                                            <div class="col-md-8 p-0">
                                                                <span id="yue"></span>元
                                                            </div>
                                                        </div>

                                                        <div class="form-group form-inline col-md-12">
                                                            <label for="money" class="col-md-3 col-form-label"><font style="vertical-align: inherit;">真实币</font></label>
                                                            <div class="col-md-8 p-0">
                                                                <input type="text" class="form-control input-full" id="fz_money" name="fz_money" placeholder="请输入正整数">
                                                            </div>
                                                        </div>


                                                        <div class="form-group form-inline col-md-12">
                                                            <label for="money" class="col-md-3 col-form-label"><font style="vertical-align: inherit;">账户币</font></label>
                                                            <div class="col-md-8 p-0">
                                                                <input type="text" class="form-control input-full" id="money" name="money" placeholder="请输入正整数">
                                                            </div>
                                                        </div>

                                                        <div class="form-group form-inline col-md-12">
                                                            <label for="money" class="col-md-3 col-form-label"><font style="vertical-align: inherit;">服务币</font></label>
                                                            <div class="col-md-8 p-0">
                                                                <input type="text" class="form-control input-full" id="fw_money" name="fw_money" placeholder="请输入正整数">
                                                            </div>
                                                        </div>

                                                        <div class="form-group form-inline col-md-12">
                                                            <label for="money" class="col-md-3 col-form-label"><font style="vertical-align: inherit;">转账时间</font></label>
                                                            <div class="col-md-8 p-0">
                                                                <input type="text" class="form-control" name="remark_time" id="time" value="" placeholder="时间">
                                                            </div>
                                                            <div class="col-md-8 p-0" style="margin-left: 120px">
                                                                <span style="color: red">以客户转账凭证日期为准</span>
                                                            </div>

                                                        </div>

                                                        <div class="form-group form-inline col-md-12">
                                                            <label for="remark" class="col-md-3 col-form-label"><font style="vertical-align: inherit;">备注</font></label>
                                                            <div class="col-md-8 p-0">
                                                                <textarea id="remark" name="remark" class="form-control input-full"></textarea>
                                                            </div>
                                                        </div>

                                                    </div>
                                                    <div class="modal-footer no-bd">
                                                        <input type="hidden" id="mer_id" name="mer_id" value="">
                                                        <button type="submit" id="addRowButton" class="btn btn-primary">保存</button>
                                                        <button type="button" class="btn btn-danger" data-dismiss="modal">关闭</button>
                                                    </div>
                                                </form>
                                            </div>

                                        </div>
                                    </div>
                                </div>

                                <div class="modal fade" id="addRowModal2" tabindex="-1" role="dialog" aria-hidden="true">
                                    <div class="modal-dialog" role="document">
                                        <div class="modal-content">
                                            <div class="modal-header no-bd">
                                                <h5 class="modal-title">
                                                    <span class="fw-mediumbold">赠送</span>

                                                </h5>
                                                <button type="button" class="close" data-dismiss="modal" aria-label="Close">
                                                    <span aria-hidden="true">&times;</span>
                                                </button>
                                            </div>
                                            <div class="modal-body">
                                                <form id="form-modal2">
                                                    <div class="row">

                                                        <div class="form-group form-inline col-md-12">
                                                            <label for="mer_name" class="col-md-3 col-form-label"><font style="vertical-align: inherit;">赠送商户</font></label>
                                                            <div class="col-md-8 p-0">
                                                                <input type="text" disabled class="form-control input-full" id="mer_name2" name="mer_name" value="">
                                                            </div>
                                                        </div>

                                                        <div class="form-group form-inline col-md-12">
                                                            <label for="" class="col-md-3 col-form-label"><font style="vertical-align: inherit;">账户币余额</font></label>
                                                            <div class="col-md-8 p-0">
                                                                <span id="yue2"></span>元
                                                            </div>
                                                        </div>

                                                        <div class="form-group form-inline col-md-12">
                                                            <label for="money" class="col-md-3 col-form-label"><font style="vertical-align: inherit;">赠送原因</font></label>
                                                            <div class="col-md-8 p-0">


                                                                <select class="form-control input-full" name="song_item" id="song_item">
                                                                    <option value="0">请选择</option>
                                                                    {volist name="song_item" id="vo"}
                                                                    <option value="{$key}">{$vo}</option>
                                                                    {/volist}
                                                                </select>
                                                            </div>
                                                        </div>

<!--                                                        <div class="form-group form-inline col-md-12">-->
<!--                                                            <label for="money" class="col-md-3 col-form-label"><font style="vertical-align: inherit;">真实币</font></label>-->
<!--                                                            <div class="col-md-8 p-0">-->
<!--                                                                <input type="text" class="form-control input-full" id="fz_money2" name="fz_money" placeholder="请输入正整数">-->
<!--                                                            </div>-->
<!--                                                        </div>-->


                                                        <div class="form-group form-inline col-md-12">
                                                            <label for="money" class="col-md-3 col-form-label"><font style="vertical-align: inherit;">账户币</font></label>
                                                            <div class="col-md-8 p-0">
                                                                <input type="text" class="form-control input-full" id="money2" name="money" placeholder="请输入正整数">
                                                            </div>
                                                        </div>


                                                        <div class="form-group form-inline col-md-12">
                                                            <label for="money" class="col-md-3 col-form-label"><font style="vertical-align: inherit;">转账时间</font></label>
                                                            <div class="col-md-8 p-0">
                                                                <input type="text" class="form-control" name="remark_time" id="time2" value="" placeholder="时间">
                                                            </div>
                                                            <div class="col-md-8 p-0" style="margin-left: 120px">
                                                                <span style="color: red">以客户转账凭证日期为准</span>
                                                            </div>

                                                        </div>

                                                        <div class="form-group form-inline col-md-12">
                                                            <label for="remark" class="col-md-3 col-form-label"><font style="vertical-align: inherit;">备注</font></label>
                                                            <div class="col-md-8 p-0">
                                                                <textarea id="remark2" name="remark" class="form-control input-full"></textarea>
                                                            </div>
                                                        </div>

                                                    </div>
                                                    <div class="modal-footer no-bd">
                                                        <input type="hidden" id="mer_id2" name="mer_id" value="">
                                                        <button type="submit" id="addRowButton2" class="btn btn-primary">保存</button>
                                                        <button type="button" class="btn btn-danger" data-dismiss="modal">关闭</button>
                                                    </div>
                                                </form>
                                            </div>

                                        </div>
                                    </div>
                                </div>


                                <div class="modal fade" id="addRowModal3" tabindex="-1" role="dialog" aria-hidden="true">
                                    <div class="modal-dialog" role="document">
                                        <div class="modal-content">
                                            <div class="modal-header no-bd">
                                                <h5 class="modal-title">
                                                    <span class="fw-mediumbold">服务币</span>

                                                </h5>
                                                <button type="button" class="close" data-dismiss="modal" aria-label="Close">
                                                    <span aria-hidden="true">&times;</span>
                                                </button>
                                            </div>
                                            <div class="modal-body">
                                                <form id="form-modal3">
                                                    <div class="row">

                                                        <div class="form-group form-inline col-md-12">
                                                            <label for="mer_name" class="col-md-3 col-form-label"><font style="vertical-align: inherit;">充值商户</font></label>
                                                            <div class="col-md-8 p-0">
                                                                <input type="text" disabled class="form-control input-full" id="mer_name3" name="mer_name" value="">
                                                            </div>
                                                        </div>

                                                        <div class="form-group form-inline col-md-12">
                                                            <label for="" class="col-md-3 col-form-label"><font style="vertical-align: inherit;">服务币余额</font></label>
                                                            <div class="col-md-8 p-0">
                                                                <span id="yue3"></span>元
                                                            </div>
                                                        </div>



                                                        <div class="form-group form-inline col-md-12">
                                                            <label for="money" class="col-md-3 col-form-label"><font style="vertical-align: inherit;">服务币</font></label>
                                                            <div class="col-md-8 p-0">
                                                                <input type="text" class="form-control input-full" id="money3" name="money" placeholder="请输入正整数">
                                                            </div>
                                                        </div>


                                                        <div class="form-group form-inline col-md-12">
                                                            <label for="money" class="col-md-3 col-form-label"><font style="vertical-align: inherit;">转账时间</font></label>
                                                            <div class="col-md-8 p-0">
                                                                <input type="text" class="form-control" name="remark_time" id="time3" value="" placeholder="时间">
                                                            </div>
                                                            <div class="col-md-8 p-0" style="margin-left: 120px">
                                                                <span style="color: red">以客户转账凭证日期为准</span>
                                                            </div>

                                                        </div>

                                                        <div class="form-group form-inline col-md-12">
                                                            <label for="remark" class="col-md-3 col-form-label"><font style="vertical-align: inherit;">备注</font></label>
                                                            <div class="col-md-8 p-0">
                                                                <textarea id="remark3" name="remark" class="form-control input-full"></textarea>
                                                            </div>
                                                        </div>

                                                    </div>
                                                    <div class="modal-footer no-bd">
                                                        <input type="hidden" id="mer_id3" name="mer_id" value="">
                                                        <button type="submit" id="addRowButton3" class="btn btn-primary">保存</button>
                                                        <button type="button" class="btn btn-danger" data-dismiss="modal">关闭</button>
                                                    </div>
                                                </form>
                                            </div>

                                        </div>
                                    </div>
                                </div>
                                

                                <div class="table-responsive">
                                    <table id="add-row" class="display table table-striped table-hover" >
                                        <thead>
                                        <tr>
                                            <th>账号</th>
                                            <th>商户</th>
                                            <th>真实币</th>
                                            <th>账户币</th>
                                            <th>服务币</th>
                                            <th>消耗</th>
                                            <th>余额</th>
                                            <th style="width: 10%">操作</th>
                                        </tr>
                                        </thead>

                                        <tbody>

                                        {volist name="infos" id="vo"}
                                        <tr>
                                            <td>{$vo.username}</td>
                                            <td>{$vo.mer_name}</td>
                                            <td>{$vo.fzmoney | format_number}</td>
                                            <td>{$vo.moneys | format_number}</td>
                                            <td>{$vo.fwmoney | format_number}</td>
                                            <td>{$vo.prices | format_number}</td>
                                            <td>
                                                总账户币余额：{$vo.balance | format_number_color}<br>
                                                总真实币余额：{$vo.balance2 | format_number_color}<br>
<!--                                                当前时段账户币余额：{$vo.timeMoney | format_number_color}<br>-->
<!--                                                当前时段真实币余额：{$vo.timeMoney2 | format_number_color}<br>-->
                                            </td>
                                            <td>
                                                {if condition="!in_array($group_id,[4,5])"}
                                                <div class="form-button-action">
                                                    <button type="button" title="充值" class="btn btn-info btn-sm" data-toggle="modal" data-target="#addRowModal" onClick="add_item('{$vo.id}','{$vo.mer_name}')">
                                                        充值
                                                    </button>
                                                </div>
                                                <div class="form-button-action">
                                                    <button type="button" title="充值" class="btn btn-info btn-sm" data-toggle="modal" data-target="#addRowModal2" onClick="add_item('{$vo.id}','{$vo.mer_name}')">
                                                        赠送
                                                    </button>
                                                </div>
<!--                                                <div class="form-button-action">-->
<!--                                                    <button type="button" title="服务币充值" class="btn btn-info btn-sm" data-toggle="modal" data-target="#addRowModal3" onClick="add_item2('{$vo.id}','{$vo.mer_name}')">-->
<!--                                                        服务币充值-->
<!--                                                    </button>-->
<!--                                                </div>-->
                                                {/if}
                                                <div class="form-button-action">
                                                    <a href="{:url('stat/charge',['mer_id'=>$vo.id])}" type="button" title="明细" class="btn btn-info btn-sm">
                                                    充值赠送明细
                                                    </a>
                                                </div>
<!--                                                <div class="form-button-action">-->
<!--                                                    <a href="{:url('stat/charge2',['mer_id'=>$vo.id])}" type="button" title="明细" class="btn btn-info btn-sm">-->
<!--                                                        服务币明细-->
<!--                                                    </a>-->
<!--                                                </div>-->
                                                <div class="form-button-action">
                                                    <a href="{:url('clueLog/index',['mer_id'=>$vo.id])}" type="button" title="明细" class="btn btn-info btn-sm">
                                                        消耗明细
                                                    </a>
                                                </div>
                                            </td>
                                        </tr>
                                        {/volist}

                                        </tbody>
                                    </table>

                                    <!-- 分页 (调取通用方法)-->
                                     <div class="layui-box layui-laypage layui-laypage-molv">{:pagination($infos)}</div>

                                </div>
                            </div>
                        </div>
                    </div>
                </div>


            </div>
        </div>

        {include file="public/_footer" /}


    </div>



</div>

{include file="public/_js" /}

</body>

<!--请在下方写此页面业务相关的脚本-->
<script type="text/javascript">
    var SCOPE = {
        'item_url':"{:url('stat/edit')}",
        'item_url2':"{:url('stat/edit2')}",
        'add_url':"{:url('stat/save')}",
        'add_url2':"{:url('stat/save2')}",
        'add_url3':"{:url('stat/save3')}",
    };

    laydate.render({
        elem: '#time'
        ,type: 'datetime'
    });
    laydate.render({
        elem: '#time2'
        ,type: 'datetime'
    });
    laydate.render({
        elem: '#time3'
        ,type: 'datetime'
    });


    $(function(){
        var commitStatus = false;
        /*表单验证*/
        $("#form-modal").validate({
            rules:{
                money:{
                    required:true,
                    number:true
                }

            },
            onkeyup:false,
            focusCleanup:true,
            success:"valid",
            submitHandler:function(form){
                var url = SCOPE.add_url;
                if(commitStatus==true){
                    return false;
                }
                var money = $("#money").val();

                /*表单提交*/
                $(form).ajaxSubmit({
                    type: 'post',
                    url: url,
                    success: function(data){
                        if(data.code == 1001){
                            commitStatus = true;
                            layer.msg(data.msg, {
                                icon: 1,
                                time: 2000
                            }, function(){
                                parent.location.reload();
                            });
                        }else{
                            layer.msg(data.msg,{icon:2,time:2000});
                        }
                    },
                    error: function(XmlHttpRequest, textStatus, errorThrown){
                        layer.msg(errorThrown,{icon:2,time:2000});
                    }
                });

            }
        });

        $("#form-modal2").validate({
            rules:{
                money:{
                    required:true,
                    number:true
                }

            },
            onkeyup:false,
            focusCleanup:true,
            success:"valid",
            submitHandler:function(form){
                var url = SCOPE.add_url2;
                if(commitStatus==true){
                    return false;
                }
                var money = $("#money").val();

                /*表单提交*/
                $(form).ajaxSubmit({
                    type: 'post',
                    url: url,
                    data:{type:2},
                    success: function(data){
                        if(data.code == 1001){
                            commitStatus = true;
                            layer.msg(data.msg, {
                                icon: 1,
                                time: 2000
                            }, function(){
                                parent.location.reload();
                            });
                        }else{
                            layer.msg(data.msg,{icon:2,time:2000});
                        }
                    },
                    error: function(XmlHttpRequest, textStatus, errorThrown){
                        layer.msg(errorThrown,{icon:2,time:2000});
                    }
                });

            }
        });

        $("#form-modal3").validate({
            rules:{
                money:{
                    required:true,
                    number:true
                }

            },
            onkeyup:false,
            focusCleanup:true,
            success:"valid",
            submitHandler:function(form){
                var url = SCOPE.add_url3;
                if(commitStatus==true){
                    return false;
                }

                /*表单提交*/
                $(form).ajaxSubmit({
                    type: 'post',
                    url: url,
                    success: function(data){
                        if(data.code == 1001){
                            commitStatus = true;
                            layer.msg(data.msg, {
                                icon: 1,
                                time: 2000
                            }, function(){
                                parent.location.reload();
                            });
                        }else{
                            layer.msg(data.msg,{icon:2,time:2000});
                        }
                    },
                    error: function(XmlHttpRequest, textStatus, errorThrown){
                        layer.msg(errorThrown,{icon:2,time:2000});
                    }
                });

            }
        });

    });

    function add_item(id,mer_name) {
        document.getElementById('form-modal').reset();
        $.ajax({
            type: 'GET',
            url: SCOPE.item_url,
            dataType: 'json',
            data: {id:id},
            success: function(res){
                if(res.code == 1001){
                    $("#yue").text(res.data.yue);
                    $("#mer_name").val(mer_name);
                    $("#mer_id").val(id);

                    $("#yue2").text(res.data.yue);
                    $("#mer_name2").val(mer_name);
                    $("#mer_id2").val(id);
                }else{
                    layer.msg(res.msg,{icon:2,time:2000});
                }
            },
            error:function(res) {
                layer.msg('网络错误,稍后再试...',{icon:2,time:2000});
            }
        });
    }
    function add_item2(id,mer_name) {
        document.getElementById('form-modal').reset();
        $.ajax({
            type: 'GET',
            url: SCOPE.item_url2,
            dataType: 'json',
            data: {id:id},
            success: function(res){
                if(res.code == 1001){
                    $("#yue").text(res.data.yue);
                    $("#mer_name").val(mer_name);
                    $("#mer_id").val(id);

                    $("#yue2").text(res.data.yue);
                    $("#mer_name2").val(mer_name);
                    $("#mer_id2").val(id);

                    $("#yue3").text(res.data.yue);
                    $("#mer_name3").val(mer_name);
                    $("#mer_id3").val(id);
                }else{
                    layer.msg(res.msg,{icon:2,time:2000});
                }
            },
            error:function(res) {
                layer.msg('网络错误,稍后再试...',{icon:2,time:2000});
            }
        });
    }

    laydate.render({
        elem: '#times'
        ,type: 'datetime'
        ,range: true
    });

    $('#orderb').val('{$orderb}');


</script>
</html>




























